package cn.whx.hrm.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class MqListener {
    //定义短信的队列名字
    public static final String QUEUE_NAME_SMS = "queue_name_SMS";
    //定义邮箱的队列名字
    public static final String QUEUE_NAME_EMAIL = "queue_name_email";
    //定义站内信的队列名字
    public static final String QUEUE_NAME_SYSTEM_MESSAGE = "queue_name_system_message";
    //定义交换机
    public static final String EXCHANGE_NAME_TOPIC = "exchange_name_topic";

    @RabbitListener(queues = {QUEUE_NAME_SMS})
    public void sendMsg(String msg, Message message, Channel channel) throws IOException {
        //调用短信
        System.out.println("短信："+"滴滴"+msg+"该课程已经发布了");
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
    }
    @RabbitListener(queues = {QUEUE_NAME_EMAIL})
    public void sendEmail(String msg, Message message, Channel channel) throws IOException {
        //调用短信
        System.out.println("短信："+"滴滴"+msg+"该课程已经发布了");
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
    }
    @RabbitListener(queues = {QUEUE_NAME_SYSTEM_MESSAGE})
    public void sendSystemMes(String msg, Message message, Channel channel) throws IOException {
        //调用短信
        System.out.println("短信："+"滴滴"+msg+"该课程已经发布了");
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
    }

}
